package com.cedric.yixianpai.game.cards.Sects.swordCards.b_ZhuJi;

import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class YinQiJian extends SwordCard {
    protected int AppendDamage = 3;
    protected int AppendCount = 2;

    /**
     * 引气剑 灵气+n(2/3/4),>n则追加3x2
     *
     * @param lvl 1/2/3
     */
    public YinQiJian(@Value("1") int lvl) {
        super("引气剑");
        this.setPeriod(Period.ZHUJI);
        this.setDescription("灵气+n(2/3/4),>n则追加3x2");
        if (1 == lvl) {
            this.setLevel(1);
            this.setSpiritAdd(2);
        } else if (2 == lvl) {
            this.setLevel(2);
            this.setSpiritAdd(3);
        } else if (3 == lvl) {
            this.setLevel(3);
            this.setSpiritAdd(4);
        } else {
            throw new RuntimeException("卡牌等级错误！");
        }
    }

    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        Sta1.getPlayerBuff().addSpiritualEnergy(this.getSpiritAdd());
        if (Sta1.getPlayerBuff().getSpiritualEnergy() > this.getSpiritAdd()) {
            for (int i = 0; i < this.AppendCount; i++) {
                Sta1.attack(Sta2, this.AppendDamage);
            }
            Sta1.getPlayerBuff().setSwordIntent(0);
        }
        return true;
    }
}
